<template>
	<view>
		<u-navbar :placeholder="true" :autoBack="true" title="修改昵称"></u-navbar>
		<view class="bg-white padding-sm">
			<view class="flex align-center justify-start">
				<text>昵称</text>
				<input class="margin-left-lg" v-model="nickname" />
			</view>
		</view>
		<view class="flex justify-center align-center margin-sm">
			<button class=" bg-tea cu-btn" style="width: 90%;" @click="submit">确认修改</button>
		</view>

	</view>

</template>

<script>
	export default {
		data() {
			return {
				nickname: ''
			}
		},
		onLoad(params) {
			this.nickname = params.nickname;
		},
		methods: {
			//确认修改昵称
			submit() {
				uni.showLoading();
				let that = this;
				uni.$u.http.post('/Customer/EditNickName', {
					nickname: this.nickname
				}).then(res => {
					let vm = uni.getStorageSync('UserInfo');
					vm.user.nickName = that.nickname;
					uni.setStorage({
						key: "UserInfo",
						data: vm
					});
					uni.showToast({
						title: res.msg,
						icon: 'success'
					})
					uni.switchTab({
						url: '/pages/index/usercenter'
					})
				});

			},

		}

	}
</script>

<style>
</style>
